# -*- coding: utf-8 -*-
# @Author: Tim Liu
# @Date: 2024-05-27
# @Last Modified by: Tim Liu
# @Last Modified time: 2024-05-27

# @Description: Knowledge Base Document Schemas for RAG

from pydantic import BaseModel, ConfigDict
from core.data_types import DatetimeStr
from apps.vadmin.auth.schemas import UserSimpleOut
from .knowledge_base import KnowledgeBaseSimpleOut


class Document(BaseModel):
    kbase_id: int | None = None
    create_user_id: int | None = None
    # add by g 20250108:增加文件类型
    file_type: str | None = None

    source_url: str | None = None
    source_type: str | None = None

    title: str | None = None
    summary: str | None = None
    content: str | None = None
    
    ingestion_status: int | None = None
    ingestion_start_time: DatetimeStr | None = None
    ingestion_end_time: DatetimeStr | None = None
    
    view_number: int | None = None
    is_active: bool | None = None
    download_url: str | None = None

class DocumentSimpleOut(Document):
    model_config = ConfigDict(from_attributes=True)

    id: int
    update_datetime: DatetimeStr
    create_datetime: DatetimeStr


class DocumentListOut(DocumentSimpleOut):
    model_config = ConfigDict(from_attributes=True)

    create_user: UserSimpleOut
    kbase: KnowledgeBaseSimpleOut
